import request from "./axios";

//登录
const login = (data) => {
  return request({
    url: "/api/login",
    method: "post",
    data,
  });
};

//注册
const register = (data) => {
  return request({
    url: "/api/register",
    method: "post",
    data,
  });
};

//登出
const logout = (data) => {
  return request({
    url: "/api/logout",
    method: "post",
    data,
  });
};

//创建房间
const addRoom = (data) => {
  return request({
    url: "/api/addRoom",
    method: "post",
    data,
  });
};

//查询房间
const selRoom = (data) => {
  return request({
    url: "/api/getRoom?userId=" + data.id,
    method: "get",
  });
};

//删除房间或退出房间
const delRoom = (data) => {
  return request({
    url: "/api/delRoom",
    method: "post",
    data,
  });
};

//查询用户信息
const selUser = (data) => {
  return request({
    url: "/api/selUser?id=" + data.id,
    method: "get",
  });
};

//更新用户信息
const updateUser = (data) => {
  return request({
    url: "/api/updateUser",
    method: "post",
    data,
  });
};

//用户修改密码
const updateUserPass = (data) => {
  return request({
    url: "/api/updateUserPass",
    method: "post",
    data,
  });
};

//查询房间的群聊成员
const groupChats = (data) => {
  return request({
    url: "/api/groupChats",
    method: "post",
    data,
  });
};

//加入群聊
const addInRoom = () => {
  return request({
    url: "/api/addInRoom",
    method: "post",
    data,
  });
};
//加入群聊
const searchUser = (data) => {
  return request({
    url: "/api/searchUser?userName=" + data.userName,
    method: "get",
  });
};
export {
  login,
  register,
  logout,
  addRoom,
  selRoom,
  selUser,
  updateUser,
  updateUserPass,
  delRoom,
  groupChats,
  addInRoom,
  searchUser,
};
